home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2005 March / Macworld CD March 2005 - Marathon Trilogy.iso / Shareware World / Text Processing / HexEdit Release.sit / HexEdit Release / Project / Source / ObjectWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-30  |  3.2 KB  |  117 lines  |  [TEXT/CWIE]

  1. /*
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is Copyright 1993 Jim Bumgardner.
  13.  * 
  14.  * The Initial Developer of the Original Code is Jim Bumgardner
  15.  * Portions created by Lane Roathe are
  16.  * Copyright (C) Copyright © 1996-2002.
  17.  * All Rights Reserved.
  18.  *
  19.  * Modified: $Date: 2002/03/20 06:39:35 $
  20.  * Revision: $Id: ObjectWindow.c,v 1.6 2002/03/20 06:39:35 raving Exp $
  21.  *
  22.  * Contributor(s):
  23.  *        Lane Roathe
  24.  *        Nick Shanks
  25.  */
  26.  
  27. // 05/10/01 - GAB: MPW environment support
  28. #ifdef __MPW__
  29. #include "MPWIncludes.h"
  30. #endif
  31.  
  32. #include "ObjectWindow.h"
  33.  
  34. /*** INIT OBJECT WINDOW ***/
  35. WindowRef InitObjectWindow( short resID, ObjectWindowPtr objectWindow, Boolean isFloating )
  36. {
  37.     if( !objectWindow )
  38.     {
  39.         objectWindow = (ObjectWindowPtr) NewPtrClear( sizeof(ObjectWindowRecord) );
  40.         if( !objectWindow ) return NULL;
  41.         objectWindow->ownStorage = true;
  42.     }
  43.     else
  44.         objectWindow->ownStorage =false;
  45.  
  46.     objectWindow->floating = false;
  47.     objectWindow->themeSavvy = (resID == kAppearanceWindow) ? true : false;    // NS 1.7.1; so we know not to draw the grow icon
  48.     objectWindow->theWin = GetNewCWindow( resID, NULL, kFirstWindowOfClass );
  49.     SetWindowKind( objectWindow->theWin, kHexEditWindowTag );            // new storage location (not in RefCon)
  50.     SetWRefCon( objectWindow->theWin, (long)objectWindow );    // new storage to stop "(ObjectWindowPtr) theWindowPtr"
  51.  
  52.     objectWindow->Update = DefaultUpdate;
  53.     objectWindow->Activate = DefaultActivate;
  54.     objectWindow->HandleClick = DefaultHandleClick;
  55.     objectWindow->Dispose = DefaultDispose;
  56.     objectWindow->Draw = DefaultDraw;
  57.     objectWindow->Idle = NULL;
  58.     objectWindow->floating = isFloating;
  59.  
  60.     return objectWindow->theWin;
  61. }
  62.  
  63.  
  64. /*** DEFAULT DISPOSE ***/
  65. void DefaultDispose( WindowRef theWin )
  66. {
  67.     ObjectWindowPtr objectWindow = (ObjectWindowPtr) GetWRefCon( theWin );
  68.  
  69.     DisposeWindow( theWin );
  70.  
  71.     if( objectWindow->ownStorage )
  72.         DisposePtr( (Ptr) theWin );
  73. }
  74.  
  75. /*** DEFAULT UPDATE ***/
  76. void DefaultUpdate( WindowRef theWin )
  77. {
  78.     ObjectWindowPtr objectWindow = (ObjectWindowPtr) GetWRefCon( theWin );
  79.     GrafPtr    savePort;
  80.  
  81.     GetPort( &savePort );
  82.  
  83.     SetPortWindowPort( theWin );
  84.     BeginUpdate( theWin );
  85.     objectWindow->Draw( theWin );
  86.     EndUpdate( theWin );
  87.  
  88.     SetPort( savePort );
  89. }
  90.  
  91. /*** DEFAULT ACTIVATE ***/
  92. void DefaultActivate( WindowRef theWin, Boolean active )
  93. {
  94.     Rect winRect;
  95.     ObjectWindowPtr objectWindow = (ObjectWindowPtr) GetWRefCon( theWin );
  96.     GrafPtr    savePort;
  97.  
  98.     GetPort( &savePort );
  99.  
  100.     GetWindowPortBounds( theWin, &winRect );
  101.     SetPortWindowPort( theWin );
  102.     InvalWindowRect( theWin, &winRect );
  103.     SetPort( savePort );
  104.     objectWindow->active = active;
  105. }
  106.  
  107. /*** DEFAULT HANDLE CLICK ***/
  108. void DefaultHandleClick( WindowRef theWin, Point where, EventRecord *er )
  109. {
  110.     #pragma unused( theWin, where, er )    // LR
  111. }
  112.  
  113. /*** DEFAULT DRAW ***/
  114. void DefaultDraw( WindowRef theWin )
  115. {
  116.     #pragma unused( theWin )    // LR
  117. }